﻿--#include "data\functions\Boss\BossBattleField.lua" once   --BOSS战场

local npcId = 150
NpcDialog[npcId] = {}
local t = NpcDialog[npcId]

t.main = function(sysarg)
	local strCond = ""
	local circleLimit= BossBattleFieldCfg.enterLevelLimit[1]
	local levelLimit = BossBattleFieldCfg.enterLevelLimit[2]

	local strColor1 = Lang.ScriptTips.Color_Greed
	if not Actor.checkActorLevel( sysarg, levelLimit, circleLimit ) then
		strColor1 = Lang.ScriptTips.Color_Red
	end

	local openDays = System.getDaysSinceOpenServer()
	local strColor4 = Lang.ScriptTips.Color_Greed
	if openDays < BossBattleFieldCfg.openServerDay then
		strColor4 = Lang.ScriptTips.Color_Red
	end

	local strCond1 = string.format( Lang.ScriptTips.LevelLimitCircleFormat, strColor1, circleLimit, levelLimit )
	local strCond4 = ""
	if BossBattleFieldCfg.openServerDay and openDays >= BossBattleFieldCfg.openServerDay then
		strCond4 = string.format( Lang.ScriptTips.LastOpenDaysLimitFormat2, strColor4  )
	else
		strCond4 = string.format( Lang.ScriptTips.LastOpenDaysLimitFormat1, strColor4, BossBattleFieldCfg.openServerDay-openDays )
	end
	strCond  = string.format("%s\n%s", strCond1, strCond4 )

	-----------------
	local strDesc = ""
	local okBtn = ""			--{按钮;样式;按钮名;函数名;描述}
	local strBtnList = ""
	strDesc 	=  Lang.ScriptTips.BossBattleFieldDesc
	okBtn1 		= "{btn;0;"..Lang.ScriptTips.ButtonEnter..";%s;}"				--{按钮;样式;按钮名;函数名;描述}
	okBtn2 		= "{btn;0;"..Lang.ScriptTips.ButtonAwards..";%s;}"
	strBtnList 	= string.format(okBtn1, "EnterBossBattleFieldFromNpc")
	strBtnList  = strBtnList .. string.format(okBtn2, "ShowBossBattleFieldAwards")

	--local localFun = string.format("OpenView,%s,%d", enLinkBuyItemWnd, cfg.itemId)
	--strBtnList = strBtnList .. string.format(cfg.buyBtn, localFun)

	-----------------
	local pack = DataPack.allocPacket(sysarg, LogicCmd.npcDialogSys.sysID, LogicCmd.npcDialogSys.sub.sNpcDlgData)
	
	DataPack.writeUint64(pack, Actor.getNpc(sysarg))
	DataPack.writeByte(pack, NpcDialogType.FYSDNpcDlg)
	DataPack.writeString(pack, strCond)
	DataPack.writeString(pack, strDesc)
	DataPack.writeString(pack, strBtnList)
	DataPack.writeChar(pack, -1)
	DataPack.writeByte(pack, 0);
	DataPack.flush(pack)

	return str
end



--进入副本
t.EnterBossBattleFieldFromNpc = function ( sysarg )
	EnterBossBattleField( sysarg )
end

--显示排行奖励
t.ShowBossBattleFieldAwards = function ( sysarg )
	Actor.openDialogs( sysarg, enLinkBossBattleFieldAwardWnd )
end
